package com.javaspeak.designpatterns.go4.creational.builder;

/**
 * This builder configures the Shape class in the parent ShapeBuilder class
 * to model a Square.
 * 
 * @author John Dickerson
 */
public class SquareBuilder extends ShapeBuilder {


    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.creational.builder.
     *      ShapeBuilder#setName()
     */
    @Override
    public void setName() {

        this.shape.name = "Square";
    }

    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.creational.builder.
     *      ShapeBuilder#buildPoints()
     */
    @Override
    public void buildPoints() {

        //   1 1 1 1
        //   1     1
        //   1     1
        //   1 1 1 1

        this.shape.points = new int[4][4];
        this.shape.points[ 0 ][ 0 ] = 1;
        this.shape.points[ 0 ][ 1 ] = 1;
        this.shape.points[ 0 ][ 2 ] = 1;
        this.shape.points[ 0 ][ 3 ] = 1;
        this.shape.points[ 1 ][ 0 ] = 1;
        this.shape.points[ 1 ][ 3 ] = 1;
        this.shape.points[ 2 ][ 0 ] = 1;
        this.shape.points[ 2 ][ 3 ] = 1;
        this.shape.points[ 3 ][ 0 ] = 1;
        this.shape.points[ 3 ][ 1 ] = 1;
        this.shape.points[ 3 ][ 2 ] = 1;
        this.shape.points[ 3 ][ 3 ] = 1;
    }

    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.creational.builder.
     *      ShapeBuilder#setPaintingLevel()
     */
    @Override
    public void setPaintingLevel() {

        // paint first
        this.shape.paintLevel = 0;
    }

    /* (non-Javadoc)
     * @see com.javaspeak.designpatterns.go4.creational.builder.
     *      ShapeBuilder#translateCoordinates()
     */
    @Override
    public void translateCoordinates() {

        // no translation necessary
    }
}
